//
// Created by Semir on 2020/4/29.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Student {
    int score;
    int age;
    string name;
    Student() : score(0), age(0), name("") {}
    Student(int score, int age, string name) : score(score), age(age), name(name) {}

    friend bool operator < (const Student (&st1), const Student (&st2)) {
        return st1.score < st2.score;
    }
};

vector<int> arr;
vector<Student> sts;
vector<Student*> ptrSts;

bool cmp1(int a, int b) {
    return a > b;
}

void test01() {
    arr.resize(15);
    arr = {12, 34, 323, 5, 54, 98, 14, 34, 123, 64};
    sort(arr.begin(),  arr.end(), cmp1);
    for (int i = 0; i < arr.size(); i++) {
        cout << arr[i] << " ";
    }
    cout << endl << arr.size() << endl;
}

bool cmp2(Student s1, Student s2) {
    return s2 < s1;
}

void test02() {
    Student s1(94, 15, "张三");
    Student s2(93, 15, "张四");
    Student s3(97, 15, "张五");
    Student s4(91, 15, "张六");
    sts.push_back(s1);
    sts.push_back(s2);
    sts.push_back(s3);
    sts.push_back(s4);
    sort(sts.begin(), sts.end(), cmp2);
    for (int i = 0; i < sts.size(); i++) {
        cout << sts[i].score << " ";
    }
    cout << endl << sts.size() << endl;
}

bool cmp3(Student* s1, Student* s2) {
    return *s2 < *s1;
}

void test03() {
    auto* s1 = new Student(94, 15, "张三");
    auto* s2 = new Student(93, 15, "张四");
    auto* s3 = new Student(97, 15, "张五");
    auto* s4 = new Student(91, 15, "张六");
    ptrSts.push_back(s1);
    ptrSts.push_back(s2);
    ptrSts.push_back(s3);
    ptrSts.push_back(s4);
    sort(ptrSts.begin(), ptrSts.end(), cmp3);
    for (int i = 0; i < ptrSts.size(); i++) {
        cout << ptrSts[i]->score << " ";
    }
    cout << endl << ptrSts.size() << endl;
}

int main() {
    test03();
    return 0;
}